<?php
	class Db extends mysqli{
		private $host_name;
		private $database_user;
		private $database_pass;
		private $database_name;
		private $db;
		
		function __construct($host_name, $database_user, $database_pass, $database_name){
			$this->host_name = $host_name;
			$this->database_user = $database_user;
			$this->database_pass = $database_pass;
			$this->database_name = $database_name;
			parent::__construct($this->host_name, $this->database_user, $this->database_pass, $this->database_name);
}
		
		
		function selectAll($table_name){
			$sql = "SELECT * FROM `%s`";
			$formatSQL = sprintf($sql, $table_name);
			$queryObj = self::query($formatSQL);
			while($result = $queryObj->fetch_assoc()){
				$rs []= $result;
			}
			return $rs;	
		}
		
		
		function totalData($table_name, $args){
			$sql = "SELECT count('%s') FROM `%s`";
			$formatSQL = sprintf($sql, $args, $table_name);
			$queryObj = self::query($formatSQL);	
			$result = $queryObj->fetch_array();
			return $result['0'];
		}
		
		
		
		function viewDebug($data, $args='0'){
			if('1' == $args){
				echo "<pre>";
				var_dump($data);
			}else if('0' == $args){
				echo "<pre>";
				print_r($data);
			}
		}
		
		function __destruct(){
			parent::close();
		}
	
	
	}


